<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改库存')" />
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    <script>
        // 获取商品列表
        $.ajax({
            url: "/oa/goods/listAll",  // 商品列表接口
            type: "GET",
            success: function(data) {
                var goodsSelect = $("#goodsId");
                $.each(data, function(index, goods) {
                    goodsSelect.append('<option value="' + goods.goodsId + '">' + goods.goodsId + '</option>');
                });
            },
            error: function(error) {
                console.error('获取商品列表失败:', error);
            }
        });
    </script>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-inventory-edit" th:object="${stockInventory}">
            <input name="goodsId" th:field="*{goodsId}" type="hidden">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">当前库存数量：</label>
                    <div class="col-sm-8">
                        <input name="currentQuantity" th:field="*{currentQuantity}" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">库存总金额：</label>
                    <div class="col-sm-8">
                        <input name="totalAmount" th:field="*{totalAmount}" class="form-control" type="text">
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "od/inventory";
        $("#form-inventory-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-inventory-edit').serialize());
            }
        }
    </script>
</body>
</html>